package com.mercury.ec.module.air.dal.mysql.order;

import com.mercury.ec.framework.common.pojo.PageResult;
import com.mercury.ec.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.mercury.ec.framework.mybatis.core.mapper.BaseMapperX;
import com.mercury.ec.module.air.controller.admin.order.vo.orderpassenger.AirOrderPassengerPageReqVO;
import com.mercury.ec.module.air.dal.dataobject.order.AirOrderPassengerDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 机票订单乘客 Mapper
 *
 * @author hesx
 */
@Mapper
public interface AirOrderPassengerMapper extends BaseMapperX<AirOrderPassengerDO> {

    default PageResult<AirOrderPassengerDO> selectPage(AirOrderPassengerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AirOrderPassengerDO>()
                .eqIfPresent(AirOrderPassengerDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(AirOrderPassengerDO::getSerialNo, reqVO.getSerialNo())
                .eqIfPresent(AirOrderPassengerDO::getType, reqVO.getType())
                .eqIfPresent(AirOrderPassengerDO::getCountryNo, reqVO.getCountryNo())
                .likeIfPresent(AirOrderPassengerDO::getName, reqVO.getName())
                .eqIfPresent(AirOrderPassengerDO::getSex, reqVO.getSex())
                .eqIfPresent(AirOrderPassengerDO::getCardType, reqVO.getCardType())
                .likeIfPresent(AirOrderPassengerDO::getCardNo, reqVO.getCardNo())
                .betweenIfPresent(AirOrderPassengerDO::getCardValidDate, reqVO.getCardValidDate())
                .eqIfPresent(AirOrderPassengerDO::getCardIssuingCountryNo, reqVO.getCardIssuingCountryNo())
                .eqIfPresent(AirOrderPassengerDO::getBirthday, reqVO.getBirthday())
                .eqIfPresent(AirOrderPassengerDO::getHaveBaby, reqVO.getHaveBaby())
                .likeIfPresent(AirOrderPassengerDO::getGuardianName, reqVO.getGuardianName())
                .likeIfPresent(AirOrderPassengerDO::getMobile, reqVO.getMobile())
                .likeIfPresent(AirOrderPassengerDO::getEmail, reqVO.getEmail())
                .betweenIfPresent(AirOrderPassengerDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AirOrderPassengerDO::getSendSms, reqVO.getSendSms())
                .orderByDesc(AirOrderPassengerDO::getId));
    }

    default List<AirOrderPassengerDO> selectByOrderId(Long orderId) {
        return selectList(AirOrderPassengerDO::getOrderId, orderId);
    }

    default void deleteByOrderId(Long orderId) {
        delete(AirOrderPassengerDO::getOrderId, orderId);
    }
}
